package one.stand.controller;

import one.stand.model.MenuModel;
import one.stand.model.ResultModel;
import one.stand.request.*;
import one.stand.response.CompanyResponse;
import one.stand.response.DynamicResponse;
import one.stand.response.VersionResponse;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
@RestController
@RequestMapping("company")
public class CompanyController extends BaseController {

    /**
     * 审核公司
     *
     * @param request
     * @return
     */
    @PostMapping("auditCompany")
    public ResultModel auditCompany(@RequestBody CompanyRequest request) {
        return companyService.auditCompany(request);
    }

    /**
     * 公司购买名片服务数
     *
     * @param request
     * @return
     */
    @PostMapping("addCompanyService")
    public ResultModel addCompanyService(@RequestBody CompanyServiceRequest request) {
        return companyService.addCompanyService(request);
    }

    /**
     * 查询总后台管理员列表
     *
     * @param request
     * @return
     */
    @PostMapping("selectAdminList")
    public ResultModel<Map<String, Object>> selectAdminList(@RequestBody AdminRequest request) {
        return companyService.selectAdminList(request);
    }

    /**
     * 删除
     *
     * @param request
     * @return
     */
    @PostMapping("delAdmin")
    public ResultModel<Boolean> delAdmin(@RequestBody AdminRequest request) {
        return companyService.delAdmin(request);
    }

    /**
     * 设置总后台管理员权限
     *
     * @param request
     * @return
     */
    @PostMapping("inserAdminRole")
    public ResultModel<Boolean> inserAdminRole(@RequestBody AdminRequest request) {
        return companyService.inserAdminRole(request);
    }

    /**
     * 查询管理员权限列表
     *
     * @return
     */
    @PostMapping("selectMenuList")
    public ResultModel<List<MenuModel>> selectMenuList() {
        return companyService.selectMenuList();
    }

    /**
     * 新增总后台管理员
     *
     * @param request
     * @return
     */
    @PostMapping("saveAdmin")
    public ResultModel<Integer> saveAdmin(@RequestBody AdminRequest request) {
        return companyService.saveAdmin(request);
    }

    /**
     * 查询企业列表
     *
     * @param request
     * @return
     */
    @PostMapping("selectCompanyList")
    public ResultModel<Map<String, Object>> selectCompanyList(@RequestBody CompanyRequest request) {
        return companyService.selectCompanyList(request);
    }

    /**
     * 查询企业信息
     *
     * @param request
     * @return
     */
    @PostMapping("getAdminCompanyInfo")
    public ResultModel<CompanyResponse> getAdminCompanyInfo(@RequestBody CompanyRequest request) {
        return companyService.getCompanyInfo(request);
    }

    /**
     * 查询代理商企业下公司的信息
     *
     * @param request
     * @return
     */
    @PostMapping("selectAgentCompanyList")
    public ResultModel<Map<String, Object>> selectAgentCompanyList(@RequestBody CompanyRequest request) {
        return companyService.selectAgentCompanyList(request);
    }

    /**
     * 设置企业购买版本，代理权限和代理价格
     *
     * @param request
     * @return
     */
    @PostMapping("configureAgen")
    public ResultModel<Boolean> configureAgen(@RequestBody CompanyRequest request) {
        return companyService.configureAgen(request);
    }

    /**
     * 查询操作记录
     *
     * @param request
     * @return
     */
    @PostMapping("selectAdminRecordList")
    public ResultModel<Map<String, Object>> selectAdminRecordList(@RequestBody AdminRecordRequest request) {
        return companyService.selectAdminRecordList(request);
    }

    /**
     * 导出企业列表
     *
     * @param request
     * @return
     */
    @PostMapping("selectCompanyListExport")
    public ResultModel<Boolean> selectCompanyListExport(@RequestBody CompanyRequest request) {
        return companyService.selectCompanyListExport(request);
    }

    /**
     * 小程序代码管理
     *
     * @param request
     * @return
     */
    @PostMapping("appletCodeManageList")
    public ResultModel<Map<String, Object>> appletCodeManageList(@RequestBody VersionRequest request) {
        return companyService.appletCodeManage(request);
    }

    /**
     * 小程序代码管理详情
     *
     * @param request
     * @return
     */
    @PostMapping("appletCodeManageInfo")
    public ResultModel<VersionResponse> appletCodeManageInfo(@RequestBody VersionRequest request) {
        return companyService.appletCodeManageInfo(request);
    }

    /**
     * 添加版本号
     *
     * @param request
     * @return
     */
    @PostMapping("addVersionInfo")
    public ResultModel<Boolean> addVersionInfo(@RequestBody VersionRequest request) {
        return companyService.addVersionInfo(request);
    }

    /**
     * 查询appid列表
     *
     * @return
     */
    @PostMapping("selectAppId")
    public ResultModel<List<String>> selectAppId(@RequestParam(value="versionId") Integer versionId) {
        return companyService.selectAppId(versionId);
    }

    /**
     * 查询公司账号列表
     *
     * @return
     */
    @PostMapping("selectCompanyAccountList")
    public ResultModel<Map<String, Object>> selectCompanyAccountList(@RequestBody CompanyAccountRequest request) {
        return companyService.selectCompanyAccountList(request);
    }

    /**
     * 为普通企业设置代理商
     *
     * @return
     */
    @PostMapping("updateAgentCompanyId")
    public ResultModel<Boolean> updateAgentCompanyId(@RequestBody CompanyRequest request) {
        return companyService.updateAgentCompanyId(request);
    }
}
